import {getTicksList,getWorkOrderHomeTop,getUserShebeiList} from '@/api/index'

// import {getTicksList , getWorkOrderHomeTop} from '@/api/SysTickets/systick'
const state = {
    ticketsList:{},
    ticketsListTop:{},
    sosDeviceInfo:{},
    redDeviceInfo:{},
    sosDeviceInfoAlarmItems:[],
    redDeviceInfoAlarmItems:[],
    // userShebeiList:[]
}
const actions = {
    async actionTicketsList({commit},pageInfo){
        const res = await getTicksList(pageInfo)
        console.log(res)
        commit('SET_TICKETSLIST',res)
    },
    async actionTickTop({commit}){
        const res = await getWorkOrderHomeTop()
        console.log(res)
        commit('SET_TICKETSLISTTOP',res)
    },
    async actionShebeiList({commit}){
        const res = await getUserShebeiList()
        // console.log(res.data)
        commit('SET_SHEBEILIST',res.data)
    }
}
const mutations = {
    SET_TICKETSLIST:(state,ticketsList)=>{
        state.ticketsList = ticketsList
    },
    SET_TICKETSLISTTOP:(state,ticketsListTop)=>{
        state.ticketsListTop = ticketsListTop
    },
    SET_SHEBEILIST:(state,userShebeiList)=>{
        // console.log(userShebeiList[0].DeviceInfo)
        state.sosDeviceInfo = userShebeiList[0].DeviceInfo
        state.redDeviceInfo = userShebeiList[1].DeviceInfo
        state.sosDeviceInfoAlarmItems = userShebeiList[0].DeviceInfoAlarmItems
        state.redDeviceInfoAlarmItems = userShebeiList[1].DeviceInfoAlarmItems
        // state.userShebeiList = userShebeiList
    }
}
// const getters={
//     sosDeviceInfo:state=>{
//         console.log(state.userShebeiList)
//         return state.userShebeiList[0].DeviceInfo
//     },
//     sosDeviceInfoAlarmItems:state=>{
//         return state.userShebeiList[0].DeviceInfoAlarmItems
//     },
//     redDeviceInfo:state=>{
//         return state.userShebeiList[1].DeviceInfo
//     },
//     redDeviceInfoAlarmItems:state=>{
//         return state.userShebeiList[1].DeviceInfoAlarmItems
//     }
// }
export default{
    namespaced:true,
    state,
    actions,
    mutations,
    // getters
}